﻿using Hazza.DigitalStore.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;


namespace Hazza.DigitalStore.Drivers
{
    public class CartWidgetPartDriver : ContentPartDriver<CartWidgetPart>
    {
        protected override string Prefix
        {
            get { return "CartWidgetPart"; }
        }

        protected override DriverResult Display(CartWidgetPart part, string displayType, dynamic shapeHelper) {
            return ContentShape("Parts_CartWidgetPart", () => shapeHelper.Parts_CartWidgetPart());
        }

        protected override DriverResult Editor(CartWidgetPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_CartWidgetPart_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/CartWidgetPart",
                    Model: part,
                    Prefix: Prefix));
        }

        protected override DriverResult Editor(CartWidgetPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}